import { createStore } from 'vuex'
import { getMusicLyric } from "@/api/request.js"
export default createStore({
  state: {
    playList:[{ //播放列表
      al: {
        id: 89039055,
        name: "雨爱(DY)",
        pic: 109951164966568500,
        picUrl: "https://p1.music.126.net/2f6UgY8Jc0Dy6jufMdIZeQ==/109951164966568495.jpg",
        pic_str: "109951164966568495"
      },
      id: 1446137141,
      name: "雨爱",
      ar:[{name: "Belien"}]

    }],
    playListIndex:0, //默认下标 0
    isbtnShow:true, //暂停按钮显示？
    detailShow:false,//歌词弹出层？
    lyricList:{}//歌词
    
  },
  getters: {
  },
  mutations: {
    updateIsbtnShow(state,value){
      state.isbtnShow = value
    },
    updatePlayList(state,value){
      state.playList = value

    },
    updatePlayListIndex(state,value){
      state.playListIndex = value
    },
    updateDetailShow(state) {
      state.detailShow = !state.detailShow
    },
    //更新歌词
    updateLyricList(state,value){
      state.lyricList=value
    },
    updateCurrentTime(state,value){
      // console.log(state.currentTime);
      state.currentTime=value
    },
    updateDuration(state,value){
      state.duration=value
    },

  },
  //异步请求
  actions: {
    async getLyric(context,value){
      let res = await getMusicLyric(value)
      console.log(res);
      context.commit("updateLyricList",res.data.lrc)

    }
    
  },
  modules: {
  }
})
